package com.atguigu.springcloud.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created with IntelliJ IDEA.
 * ClassName: GateWayConfig
 * Package: com.atguigu.springcloud.config
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-11-06
 * Time: 20:33
 */

@Configuration
public class GateWayConfig {

    //使用编码的方式配置路由和断言
    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder routeLocatorBuilder) {
        RouteLocatorBuilder.Builder routes = routeLocatorBuilder.routes();

        //分别对应配置文件种的
        //id url predicates
        routes.route("path_route_atguigu",
                r -> r.path("/guonei")
                        .uri("https://news.baidu.com/guonei")).build();

        return routes.build();
    }

}
